%% Figure output (tikzit format)
% for Welfare and Output with Income Effects and Taste Shocks
% produce figure4, figureA2/3
clear all
close all
Tf = xlsread('figdata/final_taste.xlsx');
Ti = xlsread('figdata/initial_taste.xlsx');
Tm = xlsread('figdata/Monthly_welfare.csv');

Main = [Tf(:,1),Tf(:,8),Ti(:,11),Ti(:,4) ] ;
AP = [Tf(:,1),Tf(:,4),Tf(:,12),Ti(:,7),Ti(:,15) ] ;

 axoptions={'scaled ticks = false',...
           'y tick label style={/pgf/number format/.cd, fixed, fixed zerofill,precision=2, set thousands separator={}}',...
           'x tick label style={/pgf/number format/.cd, set thousands separator={}}',...
           'legend style={font=\scriptsize}'};

figure;
plot(Main(:,1),Main(:,2),'LineWidth',1.5);hold on 
plot(Main(:,1),Main(:,3),'LineWidth',1.5)
plot(Main(:,1),Main(:,4),'LineWidth',1.5)
legend('Final Tastes','Initial Tastes','Chained','FontSize',11)
xticks(2004:2:2018);
xlim([2004 2018])
%matlab2tikz('figure4.tex','extraAxisOptions',axoptions);

%%
figure;
plot(AP(:,1),AP(:,2),'LineWidth',1.5);hold on 
plot(AP(:,1),AP(:,4),'LineWidth',1.5)
plot(AP(:,1),Main(:,4),'LineWidth',1.5)
legend('Final Tastes','Initial Tastes','Chained','FontSize',11)
xticks(2004:2:2018);
xlim([2004 2018])
%matlab2tikz('figure_Appendix_Neilsen_25.tex','extraAxisOptions',axoptions);

figure;
plot(AP(:,1),AP(:,3),'LineWidth',1.5);hold on 
plot(AP(:,1),AP(:,5),'LineWidth',1.5)
plot(AP(:,1),Main(:,4),'LineWidth',1.5)
legend('Final Tastes','Initial Tastes','Chained','FontSize',11)
xticks(2004:2:2018);
xlim([2004 2018])
%matlab2tikz('figure_Appendix_Neilsen_65.tex','extraAxisOptions',axoptions);

%%
t = datetime(2004,1,1) + calmonths(0:size(Tm,1)-1);

figure
plot(t,Tm(:,1),'LineWidth',1.5);hold on 
plot(t,Tm(:,2),'LineWidth',1.5)
plot(t,Tm(:,3),'LineWidth',1.5)
xtickformat("y")
legend('Final Tastes','Initial Tastes','Chained','FontSize',11)
legend('Final Tastes','Initial Tastes','Chained')
%matlab2tikz('figure_Appendix_Neilsen_Monthly.tex','extraAxisOptions',axoptions);